package com.shsubway.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shsubway.R;
import com.shsubway.model.GroupEntity;
import com.shsubway.model.StaffEntity;
import com.shsubway.utils.XCRoundImageView;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Hu on 2017/3/9.
 */

public class ManagementAdapter extends BaseQuickAdapter<StaffEntity, BaseViewHolder> {
    Context context;
    public ManagementAdapter(int layoutResId, List<StaffEntity> data, Context context) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, StaffEntity item) {
        Log.e("ADA",item.toString());
        helper
                .setText(R.id.user_name, TextUtils.isEmpty(item.getStaff_name()) ? "未设置" : item.getStaff_name())
                .setText(R.id.user_pre, item.getStaff_post())
                .setText(R.id.user_phone, item.getStaff_phone())
                .setText(R.id.user_address, item.getStaff_address());

        Picasso.with(context)
                .load(item.getStaff_img())
                .placeholder(item.getStaff_sex()==0?R.mipmap.header_ic:R.mipmap.heard_ic_w)
                .error(item.getStaff_sex()==0?R.mipmap.header_ic:R.mipmap.heard_ic_w)
                .into((XCRoundImageView) helper.getView(R.id.user_image));
    }
}
